class DateUtils{

  getTimeStampByDateS(dates:string):number{
    return new Date(dates).getTime()
  }

  getCurrentDateS():string{
    let currentDate = new Date()
    const year = currentDate.getFullYear();
    const month = currentDate.getMonth() + 1;
    const day = currentDate.getDate();
    return `${year}/${month}/${day}`;
  }

  /**
   * GMT时间转换为 正常北京时间(string类型)
   * @param time
   * @constructor
   */
  GMTToStr(time){
    let date = new Date(time);
    let Str=date.getFullYear() + '-' +
    (date.getMonth() + 1) + '-' +
    date.getDate() + ' ' +
    date.getHours() + ':' +
    date.getMinutes() + ':' +
    date.getSeconds();
    return Str;
  }

  /**
   * string类型转date 时间戳
   * @param date
   */

  public str_date(date){

    console.log("日期转换：");
    console.log(date);


    //前台数据转换获得时间戳 传给后台
    // @ts-ignore
    var date_m=Date.parse(date);
    // console.log(date_m);

    //将时间戳转换为GMT 格式时间
    var strDate= new Date(date_m);
    // console.log(strDate);

    //得到正常北京时间
    // @ts-ignore
    let GMTDate= this.GMTToStr(strDate);
    // console.log(GMTDate);

    //返回时间戳
    return  date_m;
  }


}

let dateUtils = new DateUtils()
export default dateUtils as DateUtils